% ufc.sty
%
% Pacote LaTeX contendo definições para facilritar a criação de trabalhos
% seguindo o Guia de Normalização da Universidade Federal do Ceará.

% Documento baseado nos modelos da UECE criados por: Rudy Matela e Sergio Correia
% Disponíveis em: http://www.larces.uece.br/~rudy/pub/modelo_monografia/ e 
% https://github.com/qrwteyrutiyoup/modelo-latex-uece
%
% Autor: Diego Victor Simões de Sousa
% Data: 10/06/2011

\RequirePackage{lastpage}

% Este pacote abaixo permite que não ocorra a hifenização no nome dos professores.
% Para a não hifenização em alguma parte do texto usar: \nohyphens
\RequirePackage{hyphenat}

\newcommand{\comentarioaprovacao}[1]{\newcommand{\ABNTcomentarioaprovacaodata}{#1}}

\newcommand{\ABNTcentrodata}{}
\newcommand{\centro}[1]{\renewcommand{\ABNTcentrodata}{#1}}

\newcommand{\ABNTdepartamentodata}{}
\newcommand{\departamento}[1]{\renewcommand{\ABNTdepartamentodata}{#1}}

\newcommand{\ABNTtipotrabalhodata}{}
\newcommand{\tipotrabalho}[1]{\renewcommand{\ABNTtipotrabalhodata}{#1}}

\newcommand{\ABNTniveldata}{}
\newcommand{\nivel}[1]{\renewcommand{\ABNTniveldata}{#1}}

\newcommand{\ABNTtituloacademicodata}{}
\newcommand{\tituloacademico}[1]{\renewcommand{\ABNTtituloacademicodata}{#1}}

\newcommand{\ABNTcursodata}{}
\newcommand{\curso}[1]{\renewcommand{\ABNTcursodata}{#1}}

\newcommand{\ABNTareaconcentracao}{}
\newcommand{\areaconcentracao}[1]{\renewcommand{\ABNTareaconcentracao}{#1}}

\newcommand{\ABNTautorrdata}{}
\newcommand{\autorr}[1]{\renewcommand{\ABNTautorrdata}{#1}}

\newcommand{\ABNTdedicatoriadata}{}
\newcommand{\dedicatoria}[1]{\renewcommand{\ABNTdedicatoriadata}{#1}}

\newcommand{\ABNTepigrafedata}{}
\newcommand{\epigrafe}[1]{\renewcommand{\ABNTepigrafedata}{#1}}

\newcommand{\ABNTautorepigrafedata}{}
\newcommand{\autorepigrafe}[1]{\renewcommand{\ABNTautorepigrafedata}{#1}}

\newcommand{\ABNTkwumdata}{}
\newcommand{\kwum}[1]{\renewcommand{\ABNTkwumdata}{#1}}
\newcommand{\ABNTkwdoisdata}{}
\newcommand{\kwdois}[1]{\renewcommand{\ABNTkwdoisdata}{#1}}
\newcommand{\ABNTkwtresdata}{}
\newcommand{\kwtres}[1]{\renewcommand{\ABNTkwtresdata}{#1}}

\newcommand{\ABNTpcumdata}{}
\newcommand{\pcum}[1]{\renewcommand{\ABNTpcumdata}{#1}}
\newcommand{\ABNTpcdoisdata}{}
\newcommand{\pcdois}[1]{\renewcommand{\ABNTpcdoisdata}{#1}}
\newcommand{\ABNTpctresdata}{}
\newcommand{\pctres}[1]{\renewcommand{\ABNTpctresdata}{#1}}

\newcommand{\ABNTbancaumdata}{}
\newcommand{\bancaum}[1]{\renewcommand{\ABNTbancaumdata}{#1}}
\newcommand{\ABNTbancadoisdata}{}
\newcommand{\bancadois}[1]{\renewcommand{\ABNTbancadoisdata}{#1}}
\newcommand{\ABNTbancatresdata}{}
\newcommand{\bancatres}[1]{\renewcommand{\ABNTbancatresdata}{#1}}
\newcommand{\ABNTbancaquatrodata}{}
\newcommand{\bancaquatro}[1]{\renewcommand{\ABNTbancaquatrodata}{#1}}

\newcommand{\ABNTcodigocipum  }{} \newcommand{\codigocipum  }[1]{\renewcommand{\ABNTcodigocipum}{#1}}
\newcommand{\ABNTcodigocipdois}{} \newcommand{\codigocipdois}[2]{\renewcommand{\ABNTcodigocipdois}{#1}}
\newcommand{\codigocip}[2]{\codigocipum{#1}\codigocipdois{#2}}

\newcommand{\ABNTcidadedata}{}
\newcommand{\cidade}[1]{\renewcommand{\ABNTcidadedata}{#1}}

\newcommand{\kws}[3]{\kwum{#1}\kwdois{#2}\kwtres{#3}}
\newcommand{\pcs}[3]{\pcum{#1}\pcdois{#2}\pctres{#3}}

\newcommand{\keywords}{
\noindent
Keywords: \ABNTkwumdata. \ABNTkwdoisdata. \ABNTkwtresdata.
}

\newcommand{\palavraschave}{
\noindent
Palavras-chave: \ABNTpcumdata. \ABNTpcdoisdata. \ABNTpctresdata.
}

% ############# CAPA #############
\renewcommand{\capa}{
	\begin{center}
	\espaco{1.1}

		\includegraphics[width=2.0cm]{fig/UFC}

		\large\ABNTchapterfont

		\MakeUppercase{\ABNTinstituicaodata}\\
		\MakeUppercase{\ABNTdepartamentodata}\\
		\MakeUppercase{Curso de \ABNTcursodata}

		\vspace{2.5cm}

		\MakeUppercase{\ABNTautordata}

		\vspace{4cm}

		\MakeUppercase{\ABNTtitulodata}\par

		\vfill

		\textbf{ \MakeUppercase{ \ABNTlocaldata} }

		\textbf{ \ABNTdatadata }

	\end{center}
	\pagebreak
	\setcounter{page}{1}
}

% ############ FOLHA DE ROSTO ###################
\renewcommand{\folhaderosto}{
	\espaco{1.1}

	\begin{center}
		\large\ABNTchapterfont\MakeUppercase\ABNTautordata\par
		\vspace{4.0cm}\par
		\large\ABNTchapterfont\MakeUppercase\ABNTtitulodata
	\end{center}

	\vspace{0.5cm}

	\hspace{.35\textwidth}
	\begin{minipage}{.5\textwidth}
		\begin{espacosimples}
			\ABNTcomentariodata\par
		\end{espacosimples}
		\hspace{.35\textwidth}
		\begin{espacosimples}
			\esparea{\numberline {Área de concentração:}}{\ignorespaces\ABNTareaconcentracao}
		\end{espacosimples}
		\hspace{.35\textwidth}
		\begin{espacosimples}
			\esporient{\numberline{Orientador:}}{\nohyphens{\ignorespaces\ABNTorientadordata}}
		\end{espacosimples}
		\ABNTifnotempty{\ABNTcoorientadordata}{
			\hspace{.35\textwidth}
			\begin{espacosimples}
				\espcoorient{\numberline {Co-Orientador:}}{\nohyphens{\ignorespaces\ABNTcoorientadordata}}
			\end{espacosimples}
		}
	\end{minipage}

	\vfill

	\begin{center}
		\textbf{\MakeUppercase\ABNTlocaldata}\par
		\textbf{\ABNTdatadata}
	\end{center}

	\pagebreak
}

% ############ TERMO DE APROVAÇÃO #############
\def\termodeaprovacao{
	\espaco{1.1}
	
	\begin{center}
		\large\ABNTchapterfont
		\MakeUppercase{\ABNTautordata}\par
		\vspace{1cm}
		\MakeUppercase{\ABNTtitulodata}
	\end{center}

%	\vspace{2cm}
%	\leftskip 0em
%	\parindent 0em
%	\@tempdima 5em
%	\begin{espacosimples}
%		\ABNTcomentariodata
%	\end{espacosimples}
%
%	\vspace{1cm}

	\vspace{1.0cm}
	\hspace{.35\textwidth}
	{
		\noindent
		\leftskip 0em
		\parindent 0em
		\begin{espacosimples}
		\ABNTcomentarioaprovacaodata Área de concentração: \ABNTareaconcentracao
		\end{espacosimples}
	}

	{
		\noindent \normalsize
		Aprovada em: \_\_/\_\_/\_\_\_\_
	}

	\vspace{1cm}

	\begin{center}
	\textbf{BANCA EXAMINADORA}
	\end{center}

	\setlength{\ABNTsignthickness}{0.4pt}
	\setlength{\ABNTsignskip}{2cm}

	\ABNTifnotempty{\ABNTbancaumdata}{
		\vspace{-0.5cm}
		\assinatura{\ABNTbancaumdata}
	}

	\ABNTifnotempty{\ABNTbancadoisdata}{
		\vspace{-0.5cm}
		\assinatura{\ABNTbancadoisdata}
	}

	\ABNTifnotempty{\ABNTbancatresdata}{
		\vspace{-0.5cm}
		\assinatura{\ABNTbancatresdata}
	}

	\ABNTifnotempty{\ABNTbancaquatrodata}{
		\vspace{-0.5cm}
		\assinatura{\ABNTbancaquatrodata}
	}

	\vfill

	\pagebreak
}


\gdef\ufcciptitle{Dados Internacionais de Catalogação na Publicação (CIP)}
\newcommand{\makecippage}{
	\vspace*{14cm}
	\begin{center}
		\cipwindow
	\end{center}
	\vfill
}


\def\cipwindow{
	\framebox[12.5cm]{
		\begin{minipage}[b][7.5cm][t]{1.5cm}
			\ABNTcodigocipum
		\end{minipage}
		\hfill
		\begin{minipage}[b][7.5cm][s]{10cm}
			\ABNTautorrdata.

			\hspace{0.4cm}
			\ABNTtitulodata\ / \ABNTautordata. \ABNTdatadata.

			\hspace{0.4cm}
			\pageref{LastPage}p.;il. color. enc.

			\ufccipdata

			\begin{flushright}
				\ABNTcodigocipdois
			\end{flushright}
		\end{minipage}
	}
}

% ############## FICHA CATALOGRÁFICA ####################
\gdef\ufccipdata{
	\small
	\hspace{0.4cm}
	Orientador: \ABNTorientadordata
	
	\ABNTifnotempty{\ABNTcoorientadordata}{
		\hspace{0.4cm}
		Coorientador: \ABNTcoorientadordata
	}

	\hspace{0.4cm}
	\ABNTtipotrabalhodata (\ABNTcursodata) - \ABNTinstituicaodata, \ABNTdepartamentodata, \ABNTcidadedata, \ABNTdatadata.
   
	\hspace{0.4cm}
	$1$. \ABNTpcumdata\ $2$. \ABNTpcdoisdata\ $3$. \ABNTpctresdata\ I. \ABNTorientadordata (Orient.) II. \ABNTinstituicaodata  -- \ABNTcursodata  (\ABNTniveldata) III. \ABNTtituloacademicodata

}



% ******** Espaços da FOLHA DE ROSTO *********
\newcommand{\esparea}[2]{
	\leftskip 0em
	\@tempdima 9.2em
	\advance\leftskip \@tempdima \null\nobreak\hskip -\leftskip
	{#1#2\hfil}}

\newcommand{\esporient}[2]{
	\leftskip 0em
	\@tempdima 4.8em
	\advance\leftskip \@tempdima \null\nobreak\hskip -\leftskip
	{#1#2\hfil}}

\newcommand{\espcoorient}[2]{
	\leftskip 0em
	\@tempdima 6.4em
	\advance\leftskip \@tempdima \null\nobreak\hskip -\leftskip
	{#1#2\hfil}}


% Altera o tamanho das fontes dos capítulos e dos apêndices
\renewcommand{\rightmarkformat}{\small}
\renewcommand{\leftmarkformat}{}
\renewcommand{\thepageformat}{\small}
\renewcommand{\ABNTchaptersize}{\Large}
\renewcommand{\ABNTCHAPTERfont}{\bfseries}
\renewcommand{\ABNTChapterfont}{\bfseries}

\renewcommand{\ABNTsectionfontsize}{\normalsize}
\renewcommand{\ABNTsectionfont}{\bfseries}
\renewcommand{\ABNTsubsectionfontsize}{\normalsize}
\renewcommand{\ABNTsubsectionfont}{\bfseries}
\renewcommand{\ABNTsubsubsectionfontsize}{\normalsize}
\renewcommand{\ABNTsubsubsectionfont}{\bfseries}
\renewcommand{\ABNTparagraphfontsize}{\normalsize}
\renewcommand{\ABNTparagraphfont}{\bfseries}
\renewcommand{\ABNTsubparagraphfontsize}{\normalsize}
\renewcommand{\ABNTsubparagraphfont}{\normalfont\bfseries}
\renewcommand{\ABNTanapsize}{\normalsize}

%Altera o espaçamento entre dots
\renewcommand\@dotsep{2}

%Altera forma de montagem do table of contents
\renewcommand\l@chapter[2]{
  \ifnum \c@tocdepth >\m@ne
    \addpenalty{-\@highpenalty}%
%      \vskip 1.5cm \@plus\p@
    \setlength\@tempdima{3.2em}%
    \begingroup
      \ifthenelse{\boolean{ABNTpagenumstyle}}
        {\renewcommand{\@pnumwidth}{3.5em}}
        {}
      \parindent \z@ \rightskip \@pnumwidth
      \parfillskip -\@pnumwidth
      \leavevmode \normalsize\ABNTtocchapterfont
      \advance\leftskip\@tempdima
      \hskip -\leftskip
      \MakeUppercase{#1}\nobreak\normalfont\dotfill\nobreak%
      \ifthenelse{\boolean{ABNTpagenumstyle}}
         {%
          \hb@xt@\@pnumwidth{\hss 
            \ifthenelse{\not\equal{#2}{}}{{\normalfont p.\thinspace#2}}{}}\par
         }
         {%
          \hb@xt@\@pnumwidth{\hss #2}\par
         }
      \penalty\@highpenalty
    \endgroup
  \fi}
  
\def\@makeanapchapterhead#1{%
  {%
%  \noindent\rule{\textwidth}{1.7pt}\\\par
  \normalfont\ABNTchapterfont\ABNTanapsize
  \espaco{simples}
  \ifthenelse{\boolean{ABNTAnApIndicativoIndent}}
    {\ifthenelse{\boolean{ABNTCapAnnexAppendix}}
       {\settowidth{\ABNTanapindent}{\MakeUppercase{\anapchaptername}
          \thechapter{} \ABNTtravessao{}}}
       {\settowidth{\ABNTanapindent}{\anapchaptername
          \thechapter{} \ABNTtravessao{}}}
    }
    {}
%   \vspace*{30pt}
%
  \raggedright\espaco{1.2}\par
  \begin{list}{}{%
       \setlength{\listparindent}{0cm}%
       \setlength{\itemindent}{-\ABNTanapindent}%
       \setlength{\rightmargin}{0cm}%
       \setlength{\leftmargin}{\ABNTanapindent}%
       \setlength{\parsep}{0pt}}%
    \item %
      \ifthenelse{\equal{#1}{}}
         {\ifthenelse{\boolean{ABNTCapAnnexAppendix}}
            {\MakeUppercase{\anapchaptername}}
            {\anapchaptername}
          \thechapter \ABNTaposindicativoanap}
         {\ifthenelse{\boolean{ABNTCapAnnexAppendix}}
            {\MakeUppercase{\anapchaptername}}                                                                                                                     
            {\anapchaptername}                                                                                                                                     
          \thechapter{} \ABNTtravessao{} \ABNTaposindicativoanap                                                                                                   
            \ifthenelse{\boolean{ABNTcapchap}}%                                                                                                                    
              {\MakeUppercase{#1}}%                                                                                                                                
              {#1}}                                                                                                                                                
  \end{list}                                                                                                                                                       
  \par\vspace{25pt}%                                                                                                                                               
  }%                      
}           


\renewcommand*\l@section[2]{\@dottedtocline{1}{0em}{3.2em}{\textbf{#1}}{#2} }
\renewcommand*\l@subsection{\normalfont\@dottedtocline{2}{0em}{3.2em}}
\renewcommand*\l@subsubsection{\@dottedtocline{3}{0em}{3.2em}}


% Cria um comando auxiliar para montagem da lista de figuras
\newcommand{\figfillnum}[1]{%
  {\hspace{1em}\normalfont\dotfill}\nobreak
  \hb@xt@\@pnumwidth{\hfil\normalfont #1}{}\par}


% Cria um comando auxiliar para montagem da lista de tabelas
\newcommand{\tabfillnum}[1]{%
	{\hspace{1em}\normalfont\dotfill}\nobreak
	\hb@xt@\@pnumwidth{\hfil\normalfont #1}{}\par}


% Altera a forma de montagem da lista de figuras
\renewcommand*{\l@figure}[2]{
	\leftskip 3.1em
	\rightskip 1.6em
	\parfillskip -\rightskip
	\parindent 0em
	\@tempdima 2.0em
	\advance\leftskip \@tempdima \null\nobreak\hskip -\leftskip
	{Figura \normalfont #1}\nobreak \figfillnum{#2}}


% Altera a forma de montagem de lista de tabelas
\renewcommand*{\l@table}[2]{
	\leftskip 3.4em
	\rightskip 1.6em
	\parfillskip -\rightskip
	\parindent 0em
	\@tempdima 2.0em
	\advance\leftskip \@tempdima \null\nobreak\hskip -\leftskip
	{Tabela \normalfont #1}\nobreak \tabfillnum{#2}}


% Define os comandos que montam a lista de símbolos
\newcommand{\listadesimbolos}{\pretextualchapter{Lista de Símbolos}\@starttoc{lsb}}
\newcommand{\simbolo}[2]{{\addcontentsline{lsb}{simbolo}{\numberline{#1}{#2}}}#1}
\newcommand{\l@simbolo}[2]{
	\vspace{-0.75cm}
	\leftskip 0em
	\parindent 0em
	\@tempdima 5em
	\advance\leftskip \@tempdima \null\nobreak\hskip -\leftskip
	{\normalfont #1}\hfil\nobreak\par}


% Define o comando que monta a lista de siglas
\newcommand{\listadesiglas}{\pretextualchapter{Lista de Siglas}\@starttoc{lsg}}
\newcommand{\sigla}[2]{{\addcontentsline{lsg}{sigla}{\numberline{#1}{#2}}}#1}
\newcommand{\l@sigla}[2]{
	\vspace{-0.75cm}
	\leftskip 0em
	\parindent 0em
	\@tempdima 5em
	\advance\leftskip \@tempdima \null\nobreak\hskip -\leftskip
	{\normalfont #1}\hfil\nobreak\par}


% Altera a posição da numeração de páginas dos elementos pré-textuais
\renewcommand\pretextualchapter{
	\if@openright\cleardoublepage\else\clearpage\fi
	\pagestyle{empty}
	\global\@topnum\z@
	\@afterindentfalse
	\@schapter}


% Altera a posição da numeração de páginas dos elementos textuais
\renewcommand{\ABNTchaptermark}[1]{
	\ifthenelse{\boolean{ABNTNextOutOfTOC}}
		{\markboth{\ABNTnextmark}{\ABNTnextmark}}
		{\chaptermark{#1}
		\pagestyle{\chaptertitlepagestyle}}}


% Redefine o tipo de numeração das páginas
\renewcommand{\ABNTBeginOfTextualPart}{
	\renewcommand{\chaptertitlepagestyle}{plainheader}
	\renewcommand{\thepage}{\arabic{page}}
	}


%Altera o tamanho do parágrafo
\setlength{\parindent}{2cm}

% Ajusta a margem superior dos capítulos (3cm)
\def\@makechapterhead#1{%
  {%
%  \noindent\rule{\textwidth}{1.7pt}\\\par
% 	\thispagestyle{empty}%
  \normalsize\bfseries%
  \espaco{simples}%
  \noindent%
  \parbox[b]{\textwidth}{%
    \parbox[t]{4ex}{\thechapter}%
    \parbox[t]{\textwidth-4ex-1ex}%
      {\interlinepenalty\@M\raggedright%
        \ifthenelse{\boolean{ABNTcapchap}}%
          {\MakeUppercase{#1}}%
          {#1}
      }%
    \vspace*{0cm}
    }\\[2pt]%
  }%
}

% Ajusta a margem superior das páginas que contêm elementos
% pre-textuais - abstract, resumo, agradecimentos, etc. (3cm) 
\def\@makeschapterhead#1{%
  {\centering\normalsize\bfseries%
   \ifthenelse{\boolean{ABNTcapchap}}%
     {\MakeUppercase{#1}}%
     {#1}
    \par}%
  \vspace{25pt}%
  \par%
}

% ############## EPÍGRAFE ######################
\def\makeepigrafe{
	\hspace{.1\textwidth}
	\vfill
	\hspace{.35\textwidth}
	\begin{minipage}{.5\textwidth}
		\par
			\ABNTepigrafedata \\ 
			\flushright{(\ABNTautorepigrafedata)}
		
	\end{minipage}
	\pagebreak
}

% ################ DEDICATÓRIA ###################
\def\makededicatoria{
	\hspace{.1\textwidth}
	\vfill
	\hspace{.5\textwidth}
	\begin{minipage}{.4\textwidth}
		\par
			\ABNTdedicatoriadata 
	\end{minipage}
	\pagebreak
}
